package com.itheima.web;

import com.itheima.service.OrderSettingService;
import com.itheima.poi.POIUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * company: www.abc.com
 * Author: 29746
 * Create Data: 2020/11/15
 */
@RestController
@RequestMapping("/ordersetting")
@Api("预约设置")
public class OrderSettingController {

    @Reference
    private OrderSettingService orderSettingService;
    //文件上传
    @PostMapping("/import")
    public boolean importFile(@RequestParam("file") MultipartFile mulitpartFile)throws Exception{
        List<String[]> data = POIUtils.readExcel(mulitpartFile);
        return orderSettingService.importFile(data);
    }


    @GetMapping("/selectByYearMonth/{year}/{month}")
    @ApiOperation("展示日历数据")
    public Map selectByYearMonth(@PathVariable("year") int year,@PathVariable("month") int month){
        return orderSettingService.selectByYearMonth(year,month);
    }

    @GetMapping("/settingDate/{day}/{num}")
    @ApiOperation("单独设置某天数据")
    public boolean settingDate(@PathVariable("day") String day,@PathVariable("num") int num){
        return orderSettingService.settingDate(day,num);
    }

}
